<template>
	<view>
		<view class='searchGood'>
			<view class='search acea-row row-between-wrapper'>
				<view class='input acea-row row-between-wrapper'>
					<text class='iconfont icon-sousuo2'></text>
					<input type='text' v-model='searchValue' placeholder='请输入店铺名称' placeholder-class='placeholder'></input>
				</view>
				<view class='bnt' @tap='searchBut'>搜索</view>
			</view>
		</view>
		<view class='wrapper'>
			<view class='list'>
				<view class='item acea-row row-between-wrapper' v-for="(item, index) in list" :key="index" @tap="goPay(item.mer_id, item.mer_name)">
					<view>
						<view class='state'>{{ item.mer_name }}</view>
					</view>
					<view class='num p-color'><view class='iconfont icon-jiantou'></view></view>
				</view>
				<view class='loadingicon acea-row row-center-wrapper' v-if="list.length > 0" @tap="loadMore">
					<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
				</view>
				<view v-else>
					<emptyPage title="暂无店铺哦～"></emptyPage>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import emptyPage from '@/components/emptyPage.vue';
	import { getStoreList } from '@/api/store.js';
	export default {
		components: {
			emptyPage
		},
		data() {
			return {
				searchValue: '',
				list: [],
				page: 1,
				limit: 10,
				loadTitle: '加载中',
				loading: true,
				isMore: true
			};
		},
		onLoad() {
			this.getList('');
		},
		methods: {
			getList(keyword) {
				getStoreList({
					keyword,
					page: this.page,
					limit: this.limit
				}).then(res => {
					console.log(res);
					this.list = this.list.concat(res.data.list);
					this.loadTitle = '点击加载更多';
					this.loading = false;
					if (res.data.list.length < this.limit) {
						this.isMore = false;
						this.loadTitle = '没有更多数据了';
					}
				})
			},
			searchBut() {
				// console.log(this.searchValue);
				this.list = [];
				this.page = 1;
				this.getList(this.searchValue);
			},
			loadMore() {
				if (this.loading || !this.isMore) {
					return
				}
				this.page++;
				this.getList(this.searchValue);
			},
			goPay(id, name) {
				uni.navigateTo({
					url: `/pages/store/writeoff/pay?id=${id}&name=${name}`
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss">
	.searchGood {
		width: 750rpx;
		position: fixed;
		top: 0;
		left: 0;
		background-color: #fff;
	}
	.searchGood .search {
		padding-left: 30rpx;
	}
	.searchGood .search {
		margin-top: 20rpx;
	}
	.searchGood .search .input {
		width: 598rpx;
		background-color: #f7f7f7;
		border-radius: 33rpx;
		padding: 0 35rpx;
		box-sizing: border-box;
		height: 66rpx;
	}
	.searchGood .search .input input {
		width: 472rpx;
		font-size: 28rpx;
	}
	.searchGood .search .input .placeholder {
		color: #bbb;
	}
	.searchGood .search .input .iconfont {
		color: #000;
		font-size: 35rpx;
	}
	.searchGood .search .bnt {
		width: 120rpx;
		text-align: center;
		height: 66rpx;
		line-height: 66rpx;
		font-size: 30rpx;
		color: #282828;
	}
	.searchGood .title {
		position: relative;
		font-size: 28rpx;
		color: #282828;
		margin: 50rpx 30rpx 25rpx 30rpx;
		.icon-shanchu {
			position: absolute;
			right: 0;
			top: 50%;
			transform: translateY(-50%);
			color: #999;
		}
	}
	.searchGood .list {
		padding: 0 10rpx;
		overflow: hidden;
	}
	.searchGood .list .item {
		font-size: 26rpx;
		color: #666;
		padding: 0 21rpx;
		height: 60rpx;
		background: rgba(242, 242, 242, 1);
		border-radius: 22rpx;
		line-height: 60rpx;
		margin: 0 0 20rpx 20rpx;
		max-width: 150rpx;
	}
	.searchGood .line {
		border-bottom: 1rpx solid #eee;
		margin: 20rpx 30rpx 0 30rpx;
	}
	.more-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 0 0 20rpx 20rpx;
		height: 60rpx;
		font-size: 24rpx;
		color: #999;
		.iconfont {
			font-size: 22rpx;
			margin-left: 10rpx;
		}
	}
	.wrapper {
		padding-top: 45px;
	}
	.wrapper .nav {
		flex: 1;
		width: 690rpx;
		border-radius: 20rpx 20rpx 0 0;
		margin: -96rpx auto 0 auto;
		background-color: #f7f7f7;
		height: 96rpx;
		font-size: 30rpx;
		color: #bbb;
	}
	
	.wrapper .nav .item {
		text-align: center;
		width: 50%;
	}
	
	.wrapper .nav .item.on {
		background-color: #fff;
		color: var(--view-theme);
		font-weight: bold;
		border-radius: 20rpx 0 0 0;
	}
	.p-color {
		color: var(--view-priceColor);
	}
	.wrapper .nav .item:nth-of-type(2).on {
		border-radius: 0 20rpx 0 0;
	}
	
	.wrapper .nav .item .iconfont {
		font-size: 38rpx;
		margin-right: 10rpx;
	}
	
	.wrapper .list {
		background-color: #fff;
		padding: 24rpx 30rpx;
	}
	
	.wrapper .list .tip {
		font-size: 25rpx;
		width: 690rpx;
		border-radius: 50rpx;
		background-color: #fff5e2;
		border: 1px solid #ffeac1;
		color: #c8a86b;
		padding: 10rpx 20rpx 10rpx 55rpx;
		box-sizing: border-box;
		margin-bottom: 24rpx;
		position: relative;
	}
	.wrapper .list .tip .iconfont {
		font-size: 35rpx;
		margin-right: 15rpx;
		position: absolute;
		top: 10rpx;
		left: 16rpx;
	}
	.wrapper .list .item {
		padding: 10px 0;
		border-bottom: 1px solid #eee;
		font-size: 32rpx;
		color: #999;
	}
	
	.wrapper .list .item .state {
		font-size: 32rpx;
		color: #282828;
		margin-bottom: 8rpx;
	}
	
	.wrapper .list .item .num {
		font-size: 36rpx;
	}
	
	.wrapper .list2 {
		background-color: #fff;
		padding: 24rpx 0;
	}
	
	.wrapper .list2 .item {
		background-image: linear-gradient(to right, #fff7e7 0%, #fffdf9 100%);
		width: 690rpx;
		height: 180rpx;
		position: relative;
		border-radius: 10rpx;
		margin: 0 auto 20rpx auto;
		padding: 0 25rpx 0 180rpx;
		box-sizing: border-box;
	}
	
	.wrapper .list2 .item .pictrue {
		width: 90rpx;
		height: 150rpx;
		position: absolute;
		bottom: 0;
		left: 45rpx;
	}
	
	.wrapper .list2 .item .pictrue image {
		width: 100%;
		height: 100%;
	}
	
	.wrapper .list2 .item .name {
		width: 285rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #c8a86b;
	}
	
	.wrapper .list2 .item .earn {
		font-size: 26rpx;
		color: #c8a86b;
		border: 2rpx solid #c8a86b;
		text-align: center;
		line-height: 52rpx;
		height: 52rpx;
		width: 160rpx;
		border-radius: 50rpx;
	}
</style>
